﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using S4Store.Persistent;
using S4Store.Domain;
using LX.Core.Query;
using S4Store.Service.Valid.StoreValid;
using S4Store.Domain.AfterSaleKpi;

namespace S4Store.Service
{
    public class DeadStockService:BaseService
    {
        public IQueryable<Domain.AfterSaleKpi.DeadStock> GetQuery()
        {
            return this.GetQuery<DeadStock>();
        }

        public void SubmitDeadStockList(int year, int month, int storeid, IList<DeadStock> list)
        {
            var CarModelMonthConfigs = this.GetQuery<DeadStock>().Where(t => t.Month.Year == year && t.Month.Month == month && t.StoreId == storeid);
            //var confirms = CarModelMonthConfigs.Where(o => o.IsConfirmed);
            //if (confirms != null && confirms.Count() > 0) throw new Exception("确认过的数据，不能再修改！");
            foreach (var Carc in CarModelMonthConfigs)
            {
                this.GetSet<DeadStock>().Remove(Carc);
            }
            foreach (var config in list)
            {
                this.GetSet<DeadStock>().Add(config);
            }
        }
    }
}
